using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class 自适应文本 : MonoBehaviour
{
    public RectTransform rectTransform; // 文本组件
    public Text text; // 文本组件

    // Update is called once per frame
    void Update()
    {
        textSize();
    }
    void textSize()
    {
        float height = text.preferredHeight;
        rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, height);
    }
}
